// https://leetcode.cn/problems/valid-square/
#include <iostream>
#include <vector>


using namespace std;
class Solution {
public:
    bool validSquare(vector<int>& p1, vector<int>& p2, vector<int>& p3, vector<int>& p4) {
		vector<long long> all = {};
		
		all.push_back(abs(p1[0]-p2[0])*abs(p1[0]-p2[0]) + abs(p1[1]-p2[1])*abs(p1[1]-p2[1]));
		all.push_back(abs(p2[0]-p3[0])*abs(p2[0]-p3[0]) + abs(p2[1]-p3[1])*abs(p2[1]-p3[1]));
		all.push_back(abs(p3[0]-p4[0])*abs(p3[0]-p4[0]) + abs(p3[1]-p4[1])*abs(p3[1]-p4[1]));
		all.push_back(abs(p1[0]-p4[0])*abs(p1[0]-p4[0]) + abs(p1[1]-p4[1])*abs(p1[1]-p4[1]));
		all.push_back(abs(p1[0]-p3[0])*abs(p1[0]-p3[0]) + abs(p1[1]-p3[1])*abs(p1[1]-p3[1]));
		all.push_back(abs(p2[0]-p4[0])*abs(p2[0]-p4[0]) + abs(p2[1]-p4[1])*abs(p2[1]-p4[1]));
		
		long long minLen = min(min(all[0],all[1]),all[2]);
		vector<long long> sideV = {};
		vector<long long> pondV = {};
		for(auto i : all){
			if(i == minLen) 
				sideV.push_back(i);
			else
				pondV.push_back(i);
		}
		if(sideV.size() != 4 || pondV[0] != pondV[1] || sideV[0] + sideV[1] != pondV[0]) return false;
		return true;
		// cout << len13 << "-"<< len24 << endl;
		// cout << len12 << "-"<< len23<< "-" << len34 << "-"<< len41 << endl;
		
		
		// if(minLen)
		// long long sumLen = len12 + len23 + len34 + len41 + len13 + len24;
		// if(minLen != 0 && sumLen % minLen == 0 && sumLen/minLen == 8) return true;
		// return false;
		
		
		
    }
};

int main(){
	vector<int>p1 = {0,0};
	vector<int>p2 = {13,0};
	vector<int>p3 = {5,12};
	vector<int>p4 = {18,12};
	Solution so;
	if(so.validSquare(p1,p2,p3,p4)){
		cout << 123 <<endl;
	}
	return 0;
	
}